﻿using System;
using System.IO;
using System.Text;
using System.Xml;

namespace Kotonoha.Server.Xml {

    public class XmlParser {
        private readonly ElementHandler root;

        public XmlParser(ElementHandler root) {
            this.root = root;
        }

        public void parse(Stream s) {
            XmlReaderSettings settings = new XmlReaderSettings {
                                                                   CloseInput = true, 
                                                                   IgnoreComments = true, 
                                                                   IgnoreProcessingInstructions = true,
                                                                   IgnoreWhitespace = true,
                                                                   ProhibitDtd = false
                                                               };
            
            XmlReader reader = XmlReader.Create(s, settings);
            root.read(reader);
            reader.Close();
        }
    }

    public delegate void StringContentAction(String s);

    public delegate void IntContentAction(int i);

    public delegate void ElementAction(Element e);

    public delegate void ReaderAction(XmlReader reader);

    public delegate void SimpleAction();
}
